<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://dublincore.org/documents/2008/08/04/dc-html/">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="robots" content="index,follow" />
    <meta name="creator" content="rfcmarkup version 1.89" />
    <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />
<meta name="DC.Identifier" content="urn:ietf:rfc:4180" />
<meta name="DC.Description.Abstract" content="This RFC documents the format used for Comma-Separated Values (CSV)\nfiles and registers the associated MIME type "text/csv". This memo\nprovides information for the Internet community." />
<meta name="DC.Creator" content="Y. Shafranovich" />
<meta name="DC.Date.Issued" content="October, 2005" />
<meta name="DC.Title" content="Common Format and MIME Type for Comma-Separated Values (CSV) Files" />

    <link rel="icon" href="/images/rfc.png" type="image/png" />
    <link rel="shortcut icon" href="/images/rfc.png" type="image/png" />
    <title>RFC 4180 - Common Format and MIME Type for Comma-Separated Values (CSV) Files</title>
    
    
    <style type="text/css">
	body {
	    margin: 0px 8px;
            font-size: 1em;
	}
        h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
	    font-weight: bold;
            line-height: 0pt;
            display: inline;
            white-space: pre;
            font-family: monospace;
            font-size: 1em;
	    font-weight: bold;
        }
        pre {
            font-size: 1em;
            margin-top: 0px;
            margin-bottom: 0px;
        }
	.pre {
	    white-space: pre;
	    font-family: monospace;
	}
	.header{
	    font-weight: bold;
	}
        .newpage {
            page-break-before: always;
        }
        .invisible {
            text-decoration: none;
            color: white;
        }
        @media print {
            body {
                font-size: 10.5pt;
            }
            h1, h2, h3, h4, h5, h6 {
                font-size: 10.5pt;
            }
        
            a:link, a:visited {
                color: inherit;
                text-decoration: none;
            }
            .noprint {
                display: none;
            }
        }
	@media screen {
	    .grey, .grey a:link, .grey a:visited {
		color: #777;
	    }
            .docinfo {
                background-color: #EEE;
            }
            .top {
                border-top: 7px solid #EEE;
            }
            .bgwhite  { background-color: white; }
            .bgred    { background-color: #F44; }
            .bggrey   { background-color: #666; }
            .bgbrown  { background-color: #840; }            
            .bgorange { background-color: #FA0; }
            .bgyellow { background-color: #EE0; }
            .bgmagenta{ background-color: #F4F; }
            .bgblue   { background-color: #66F; }
            .bgcyan   { background-color: #4DD; }
            .bggreen  { background-color: #4F4; }

            .legend   { font-size: 90%; }
            .cplate   { font-size: 70%; border: solid grey 1px; }
	}
    </style>
    <!--[if IE]>
    <style>
    body {
       font-size: 13px;
       margin: 10px 10px;
    }
    </style>
    <![endif]-->

    <script type="text/javascript"><!--
    function addHeaderTags() {
	var spans = document.getElementsByTagName("span");
	for (var i=0; i < spans.length; i++) {
	    var elem = spans[i];
	    if (elem) {
		var level = elem.getAttribute("class");
                if (level == "h1" || level == "h2" || level == "h3" || level == "h4" || level == "h5" || level == "h6") {
                    elem.innerHTML = "<"+level+">"+elem.innerHTML+"</"+level+">";		
                }
	    }
	}
    }
    var legend_html = "Colour legend:<br />      <table>         <tr><td>Unknown:</td>          <td><span class='cplate bgwhite'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>         <tr><td>Draft:</td>            <td><span class='cplate bgred'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>         <tr><td>Informational:</td>    <td><span class='cplate bgorange'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>         <tr><td>Experimental:</td>     <td><span class='cplate bgyellow'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>         <tr><td>Best Common Practice:</td><td><span class='cplate bgmagenta'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>         <tr><td>Proposed Standard:</td><td><span class='cplate bgblue'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>         <tr><td>Draft Standard:</td>   <td><span class='cplate bgcyan'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>         <tr><td>Standard:</td>         <td><span class='cplate bggreen'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>         <tr><td>Historic:</td>         <td><span class='cplate bggrey'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>         <tr><td>Obsolete:</td>         <td><span class='cplate bgbrown'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>     </table>";
    function showElem(id) {
        var elem = document.getElementById(id);
        elem.innerHTML = eval(id+"_html");
        elem.style.visibility='visible';
    }
    function hideElem(id) {
        var elem = document.getElementById(id);
        elem.style.visibility='hidden';        
        elem.innerHTML = "";
    }
    // -->
    </script>
</head>
<body onload="addHeaderTags()">
   <div style="height: 13px;">
      <div onmouseover="this.style.cursor='pointer';"
         onclick="showElem('legend');"
         onmouseout="hideElem('legend')"
	 style="height: 6px; position: absolute;"
         class="pre noprint docinfo bgorange"
         title="Click for colour legend." >                                                                        </div>
      <div id="legend"
           class="docinfo noprint pre legend"
           style="position:absolute; top: 4px; left: 4ex; visibility:hidden; background-color: white; padding: 4px 9px 5px 7px; border: solid #345 1px; "
           onmouseover="showElem('legend');"
           onmouseout="hideElem('legend');">
      </div>
   </div>
<span class="pre noprint docinfo top">[<a href="../html/" title="Document search and retrieval page">Docs</a>] [<a href="/rfc/rfc4180.txt" title="Plaintext version of this document">txt</a>] [<a href="/pdf/rfc4180" title="PDF version of this document">pdf</a>] [<a href="draft-shafranovich-mime-csv" title="draft-shafranovich-mime-csv">draft-shafranovic...</a>] [<a href="/rfcdiff?difftype=--hwdiff&amp;url2=rfc4180" title="Inline diff (wdiff)">Diff1</a>] [<a href="/rfcdiff?url2=rfc4180" title="Side-by-side diff">Diff2</a>]               </span><br />
<span class="pre noprint docinfo">                                                                        </span><br />
<span class="pre noprint docinfo">                                                           INFORMATIONAL</span><br />
<span class="pre noprint docinfo">                                                                        </span><br />
<pre>
Network Working Group                                    Y. Shafranovich
Request for Comments: 4180                SolidMatrix Technologies, Inc.
Category: Informational                                     October 2005


   <span class="h1">Common Format and MIME Type for Comma-Separated Values (CSV) Files</span>

Status of This Memo

   This memo provides information for the Internet community.  It does
   not specify an Internet standard of any kind.  Distribution of this
   memo is unlimited.

Copyright Notice

   Copyright (C) The Internet Society (2005).

Abstract

   This RFC documents the format used for Comma-Separated Values (CSV)
   files and registers the associated MIME type "text/csv".

Table of Contents

   <a href="#section-1">1</a>. Introduction ....................................................<a href="#page-2">2</a>
   <a href="#section-2">2</a>. Definition of the CSV Format ....................................<a href="#page-2">2</a>
   <a href="#section-3">3</a>. MIME Type Registration of text/csv ..............................<a href="#page-4">4</a>
   <a href="#section-4">4</a>. IANA Considerations .............................................<a href="#page-5">5</a>
   <a href="#section-5">5</a>. Security Considerations .........................................<a href="#page-5">5</a>
   <a href="#section-6">6</a>. Acknowledgments .................................................<a href="#page-6">6</a>
   <a href="#section-7">7</a>. References ......................................................<a href="#page-6">6</a>
      <a href="#section-7.1">7.1</a>. Normative References .......................................<a href="#page-6">6</a>
      <a href="#section-7.2">7.2</a>. Informative References .....................................<a href="#page-6">6</a>


















<span class="grey">Shafranovich                 Informational                      [Page 1]</span>
</pre><pre class='newpage'><a name="page-2" id="page-2" href="#page-2" class="invisible"> </a>
<span class="grey"><a href="./rfc4180">RFC 4180</a>       Common Format and MIME Type for CSV Files    October 2005</span>


<span class="h2"><a name="section-1">1</a>.  Introduction</span>

   The comma separated values format (CSV) has been used for exchanging
   and converting data between various spreadsheet programs for quite
   some time.  Surprisingly, while this format is very common, it has
   never been formally documented.  Additionally, while the IANA MIME
   registration tree includes a registration for
   "text/tab-separated-values" type, no MIME types have ever been
   registered with IANA for CSV.  At the same time, various programs and
   operating systems have begun to use different MIME types for this
   format.  This RFC documents the format of comma separated values
   (CSV) files and formally registers the "text/csv" MIME type for CSV
   in accordance with <a href="./rfc2048">RFC 2048</a> [<a href="#ref-1" title='"Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"'>1</a>].

<span class="h2"><a name="section-2">2</a>.  Definition of the CSV Format</span>

   While there are various specifications and implementations for the
   CSV format (for ex. [<a href="#ref-4" title='"HOW-TO: The Comma Separated Value (CSV) File Format"'>4</a>], [<a href="#ref-5" title='"CSV Standard File Format"'>5</a>], [<a href="#ref-6" title='"Documentation for Ricebridge CSV Manager"'>6</a>] and [<a href="#ref-7" title='"The Art of Unix Programming, Chapter 5"'>7</a>]), there is no formal
   specification in existence, which allows for a wide variety of
   interpretations of CSV files.  This section documents the format that
   seems to be followed by most implementations:

   1.  Each record is located on a separate line, delimited by a line
       break (CRLF).  For example:

       aaa,bbb,ccc CRLF
       zzz,yyy,xxx CRLF

   2.  The last record in the file may or may not have an ending line
       break.  For example:

       aaa,bbb,ccc CRLF
       zzz,yyy,xxx

   3.  There maybe an optional header line appearing as the first line
       of the file with the same format as normal record lines.  This
       header will contain names corresponding to the fields in the file
       and should contain the same number of fields as the records in
       the rest of the file (the presence or absence of the header line
       should be indicated via the optional "header" parameter of this
       MIME type).  For example:

       field_name,field_name,field_name CRLF
       aaa,bbb,ccc CRLF
       zzz,yyy,xxx CRLF






<span class="grey">Shafranovich                 Informational                      [Page 2]</span>
</pre><pre class='newpage'><a name="page-3" id="page-3" href="#page-3" class="invisible"> </a>
<span class="grey"><a href="./rfc4180">RFC 4180</a>       Common Format and MIME Type for CSV Files    October 2005</span>


   4.  Within the header and each record, there may be one or more
       fields, separated by commas.  Each line should contain the same
       number of fields throughout the file.  Spaces are considered part
       of a field and should not be ignored.  The last field in the
       record must not be followed by a comma.  For example:

       aaa,bbb,ccc

   5.  Each field may or may not be enclosed in double quotes (however
       some programs, such as Microsoft Excel, do not use double quotes
       at all).  If fields are not enclosed with double quotes, then
       double quotes may not appear inside the fields.  For example:

       "aaa","bbb","ccc" CRLF
       zzz,yyy,xxx

   6.  Fields containing line breaks (CRLF), double quotes, and commas
       should be enclosed in double-quotes.  For example:

       "aaa","b CRLF
       bb","ccc" CRLF
       zzz,yyy,xxx

   7.  If double-quotes are used to enclose fields, then a double-quote
       appearing inside a field must be escaped by preceding it with
       another double quote.  For example:

       "aaa","b""bb","ccc"

   The ABNF grammar [<a href="#ref-2" title='"Augmented BNF for Syntax Specifications: ABNF"'>2</a>] appears as follows:

   file = [header CRLF] record *(CRLF record) [CRLF]

   header = name *(COMMA name)

   record = field *(COMMA field)

   name = field

   field = (escaped / non-escaped)

   escaped = DQUOTE *(TEXTDATA / COMMA / CR / LF / 2DQUOTE) DQUOTE

   non-escaped = *TEXTDATA

   COMMA = %x2C

   CR = %x0D ;as per <a href="./rfc2234#section-6.1">section&nbsp;6.1 of RFC 2234</a> [<a href="#ref-2" title='"Augmented BNF for Syntax Specifications: ABNF"'>2</a>]



<span class="grey">Shafranovich                 Informational                      [Page 3]</span>
</pre><pre class='newpage'><a name="page-4" id="page-4" href="#page-4" class="invisible"> </a>
<span class="grey"><a href="./rfc4180">RFC 4180</a>       Common Format and MIME Type for CSV Files    October 2005</span>


   DQUOTE =  %x22 ;as per <a href="./rfc2234#section-6.1">section&nbsp;6.1 of RFC 2234</a> [<a href="#ref-2" title='"Augmented BNF for Syntax Specifications: ABNF"'>2</a>]

   LF = %x0A ;as per <a href="./rfc2234#section-6.1">section&nbsp;6.1 of RFC 2234</a> [<a href="#ref-2" title='"Augmented BNF for Syntax Specifications: ABNF"'>2</a>]

   CRLF = CR LF ;as per <a href="./rfc2234#section-6.1">section&nbsp;6.1 of RFC 2234</a> [<a href="#ref-2" title='"Augmented BNF for Syntax Specifications: ABNF"'>2</a>]

   TEXTDATA =  %x20-21 / %x23-2B / %x2D-7E

<span class="h2"><a name="section-3">3</a>.  MIME Type Registration of text/csv</span>

   This section provides the media-type registration application (as per
   <a href="./rfc2048">RFC 2048</a> [<a href="#ref-1" title='"Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"'>1</a>].

   To: ietf-types@iana.org

   Subject: Registration of MIME media type text/csv

   MIME media type name: text

   MIME subtype name: csv

   Required parameters: none

   Optional parameters: charset, header

      Common usage of CSV is US-ASCII, but other character sets defined
      by IANA for the "text" tree may be used in conjunction with the
      "charset" parameter.

      The "header" parameter indicates the presence or absence of the
      header line.  Valid values are "present" or "absent".
      Implementors choosing not to use this parameter must make their
      own decisions as to whether the header line is present or absent.

   Encoding considerations:

      As per <a href="#section-4.1.1">section 4.1.1</a>. of <a href="./rfc2046">RFC 2046</a> [<a href="#ref-3" title='"Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"'>3</a>], this media type uses CRLF
      to denote line breaks.  However, implementors should be aware that
      some implementations may use other values.

   Security considerations:

      CSV files contain passive text data that should not pose any
      risks.  However, it is possible in theory that malicious binary
      data may be included in order to exploit potential buffer overruns
      in the program processing CSV data.  Additionally, private data
      may be shared via this format (which of course applies to any text
      data).



<span class="grey">Shafranovich                 Informational                      [Page 4]</span>
</pre><pre class='newpage'><a name="page-5" id="page-5" href="#page-5" class="invisible"> </a>
<span class="grey"><a href="./rfc4180">RFC 4180</a>       Common Format and MIME Type for CSV Files    October 2005</span>


   Interoperability considerations:

      Due to lack of a single specification, there are considerable
      differences among implementations.  Implementors should "be
      conservative in what you do, be liberal in what you accept from
      others" (<a href="./rfc793">RFC 793</a> [<a href="#ref-8" title='"Transmission Control Protocol"'>8</a>]) when processing CSV files.  An attempt at a
      common definition can be found in <a href="#section-2">Section 2</a>.

      Implementations deciding not to use the optional "header"
      parameter must make their own decision as to whether the header is
      absent or present.

   Published specification:

      While numerous private specifications exist for various programs
      and systems, there is no single "master" specification for this
      format.  An attempt at a common definition can be found in <a href="#section-      ">Section</a>
      <a href="#section-      ">2</a>.

   Applications that use this media type:

      Spreadsheet programs and various data conversion utilities

   Additional information:

      Magic number(s): none

      File extension(s): CSV

      Macintosh File Type Code(s): TEXT

   Person &amp; email address to contact for further information:

      Yakov Shafranovich &lt;ietf@shaftek.org&gt;

   Intended usage: COMMON

   Author/Change controller: IESG

<span class="h2"><a name="section-4">4</a>.  IANA Considerations</span>

   The IANA has registered the MIME type "text/csv" using the
   application provided in <a href="#section-3">Section 3</a> of this document.

<span class="h2"><a name="section-5">5</a>.  Security Considerations</span>

   See discussion above in <a href="#section-3">section 3</a>.




<span class="grey">Shafranovich                 Informational                      [Page 5]</span>
</pre><pre class='newpage'><a name="page-6" id="page-6" href="#page-6" class="invisible"> </a>
<span class="grey"><a href="./rfc4180">RFC 4180</a>       Common Format and MIME Type for CSV Files    October 2005</span>


<span class="h2"><a name="section-6">6</a>.  Acknowledgments</span>

   The author would like to thank Dave Crocker, Martin Duerst, Joel M.
   Halpern, Clyde Ingram, Graham Klyne, Bruce Lilly, Chris Lilley, and
   members of the IESG for their helpful suggestions.  A special word of
   thanks goes to Dave for helping with the ABNF grammar.

   The author would also like to thank Henrik Lefkowetz, Marshall Rose,
   and the folks at xml.resource.org for providing many of the tools
   used for preparing RFCs and Internet drafts.

   A special thank you goes to L.T.S.

<span class="h2"><a name="section-7">7</a>.  References</span>

<span class="h3"><a name="section-7.1">7.1</a>.  Normative References</span>

   [<a name="ref-1" id="ref-1">1</a>]  Freed, N., Klensin, J., and J. Postel, "Multipurpose Internet
        Mail Extensions (MIME) Part Four: Registration Procedures", <a href="./bcp13">BCP</a>
        <a href="./bcp13">13</a>, <a href="./rfc2048">RFC 2048</a>, November 1996.

   [<a name="ref-2" id="ref-2">2</a>]  Crocker, D. and P. Overell, "Augmented BNF for Syntax
        Specifications: ABNF", <a href="./rfc2234">RFC 2234</a>, November 1997.

   [<a name="ref-3" id="ref-3">3</a>]  Freed, N. and N. Borenstein, "Multipurpose Internet Mail
        Extensions (MIME) Part Two: Media Types", <a href="./rfc2046">RFC 2046</a>, November
        1996.

<span class="h3"><a name="section-7.2">7.2</a>.  Informative References</span>

   [<a name="ref-4" id="ref-4">4</a>]  Repici, J., "HOW-TO: The Comma Separated Value (CSV) File
        Format", 2004,
        &lt;<a href="http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm">http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm</a>&gt;.

   [<a name="ref-5" id="ref-5">5</a>]  Edoceo, Inc., "CSV Standard File Format", 2004,
        &lt;<a href="http://www.edoceo.com/utilis/csv-file-format.php">http://www.edoceo.com/utilis/csv-file-format.php</a>&gt;.

   [<a name="ref-6" id="ref-6">6</a>]  Rodger, R. and O. Shanaghy, "Documentation for Ricebridge CSV
        Manager", February 2005,
        &lt;<a href="http://www.ricebridge.com/products/csvman/reference.htm">http://www.ricebridge.com/products/csvman/reference.htm</a>&gt;.

   [<a name="ref-7" id="ref-7">7</a>]  Raymond, E., "The Art of Unix Programming, Chapter 5", September
        2003,
        &lt;<a href="http://www.catb.org/~esr/writings/taoup/html/ch05s02.html">http://www.catb.org/~esr/writings/taoup/html/ch05s02.html</a>&gt;.

   [<a name="ref-8" id="ref-8">8</a>]  Postel, J., "Transmission Control Protocol", STD 7, <a href="./rfc793">RFC 793</a>,
        September 1981.




<span class="grey">Shafranovich                 Informational                      [Page 6]</span>
</pre><pre class='newpage'><a name="page-7" id="page-7" href="#page-7" class="invisible"> </a>
<span class="grey"><a href="./rfc4180">RFC 4180</a>       Common Format and MIME Type for CSV Files    October 2005</span>


Author's Address

   Yakov Shafranovich
   SolidMatrix Technologies, Inc.

   EMail: ietf@shaftek.org
   URI:   <a href="http://www.shaftek.org">http://www.shaftek.org</a>












































<span class="grey">Shafranovich                 Informational                      [Page 7]</span>
</pre><pre class='newpage'><a name="page-8" id="page-8" href="#page-8" class="invisible"> </a>
<span class="grey"><a href="./rfc4180">RFC 4180</a>       Common Format and MIME Type for CSV Files    October 2005</span>


Full Copyright Statement

   Copyright (C) The Internet Society (2005).

   This document is subject to the rights, licenses and restrictions
   contained in <a href="./bcp78">BCP 78</a>, and except as set forth therein, the authors
   retain all their rights.

   This document and the information contained herein are provided on an
   "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
   OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
   ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
   INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
   INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

Intellectual Property

   The IETF takes no position regarding the validity or scope of any
   Intellectual Property Rights or other rights that might be claimed to
   pertain to the implementation or use of the technology described in
   this document or the extent to which any license under such rights
   might or might not be available; nor does it represent that it has
   made any independent effort to identify any such rights.  Information
   on the procedures with respect to rights in RFC documents can be
   found in <a href="./bcp78">BCP 78</a> and <a href="./bcp79">BCP 79</a>.

   Copies of IPR disclosures made to the IETF Secretariat and any
   assurances of licenses to be made available, or the result of an
   attempt made to obtain a general license or permission for the use of
   such proprietary rights by implementers or users of this
   specification can be obtained from the IETF on-line IPR repository at
   <a href="http://www.ietf.org/ipr">http://www.ietf.org/ipr</a>.

   The IETF invites any interested party to bring to its attention any
   copyrights, patents or patent applications, or other proprietary
   rights that may cover technology that may be required to implement
   this standard.  Please address the information to the IETF at ietf-
   ipr@ietf.org.

Acknowledgement

   Funding for the RFC Editor function is currently provided by the
   Internet Society.







Shafranovich                 Informational                      [Page 8]
</pre><pre class='newpage'>

</pre><br />
<span class="noprint"><small><small>Html markup produced by rfcmarkup 1.89, available from
<a href="http://tools.ietf.org/tools/rfcmarkup/">http://tools.ietf.org/tools/rfcmarkup/</a>
</small></small></span>
</body></html>
